package com.example.mylsposed;

import android.app.Application;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.media.MediaPlayer;
import android.util.Log;
import android.view.Surface;

import java.io.IOException;
import java.lang.reflect.Field;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class CameraHook implements IXposedHookLoadPackage {
    private final String TAG = "CameraHook";
    private SurfaceTexture st = null;
    public static Camera camera;
    public static Surface mSurface;
    public static MediaPlayer mMediaPlayer;

    @Override
    public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        XposedBridge.log("load_app:" + lpparam.packageName);
        Log.i(TAG, "handleLoadPackage: ");


        if (lpparam.packageName.equals("com.example.mylsposed")) {
            XposedHelpers.findAndHookMethod("com.example.mylsposed.MainActivity", lpparam.classLoader,
                    "isModuleActive",
                    XC_MethodReplacement.returnConstant(true));
        }
        if (lpparam.packageName.equals("com.example.phonerecordjava")) {
            XposedHelpers.findAndHookMethod("com.example.phonerecordjava.main.MainActivity", lpparam.classLoader,
                    "isModuleActive",
                    XC_MethodReplacement.returnConstant(true));
        }
    }
}
